export interface ClickOutsideOptions {
  /**
   * 处理器的唯一标识符
   */
  id?: string
  /**
   * 点击外部时触发的回调函数
   */
  onOutsideClick: (event: MouseEvent) => void
  /**
   * 需要排除的元素选择器或元素
   */
  excludeSelectors?: string[]
  /**
   * 是否启用捕获阶段
   * @default true
   */
  useCapture?: boolean
  /**
   * 是否启用功能
   * @default true
   */
  enabled?: boolean
  /**
   * 自定义条件判断函数
   */
  condition?: (event: MouseEvent, target: Element) => boolean
}

export interface ClickOutsideHandler {
  /**
   * 启用点击外部监听
   */
  enable: () => void
  /**
   * 禁用点击外部监听
   */
  disable: () => void
  /**
   * 销毁处理器
   */
  destroy: () => void
  /**
   * 检查是否已启用
   */
  isEnabled: () => boolean
}

export interface ClickOutsideResult {
  /**
   * 处理器实例
   */
  handler: ClickOutsideHandler
  /**
   * 启用监听
   */
  enable: () => void
  /**
   * 禁用监听
   */
  disable: () => void
  /**
   * 销毁监听
   */
  destroy: () => void
}

export const DEFAULT_CLICK_OUTSIDE_OPTIONS: Required<ClickOutsideOptions> = {
  id: 'default-click-outside',
  excludeSelectors: [],
  useCapture: true,
  enabled: true,
  condition: () => true,
  onOutsideClick: (_event: MouseEvent) => {},
}
